#
# $Id: Makefile 161 2007-11-30 07:19:52Z balaji $
#
# Copyright (C) 2006-2007, University of Chicago. All rights reserved.
#

.PHONY: all clean complete

tex_files = $(wildcard *.tex */*.tex */*/*.tex */*/*/*.tex)
bib_files = $(wildcard *.bib */*.bib */*/*.bib */*/*/*.bib)
eps_files = $(wildcard *.eps */*.eps */*/*.eps */*/*/*.eps)
epsi_files = $(wildcard *.epsi */*.epsi */*/*.epsi */*/*/*.epsi)
ps_files = $(wildcard */*.ps */*/*.ps */*/*/*.ps)

header: header.tex $(tex_files) $(bib_files)
	@if test "`which rubber `" != "" ; then \
		rubber -d header ; \
	else \
		pdflatex header | tee latex.out ; \
		if grep -q '^LaTeX Warning: Citation.*undefined' latex.out; then \
			bibtex header; \
			touch .rebuild; \
		fi ; \
		while [ -f .rebuild -o \
			-n "`grep '^LaTeX Warning:.*Rerun' latex.out`" ]; do \
			rm -f .rebuild; \
			pdflatex header | tee latex.out; \
		done ; \
		rm latex.out ; \
	fi

clean:
	find . \( -name '*.blg' -print \) -or \( -name '*.aux' -print \) -or \
		\( -name '*.bbl' -print \) -or \( -name '*~' -print \) -or \
		\( -name '*.lof' -print \) -or \( -name '*.lot' -print \) -or \
		\( -name '*.toc' -print \) | xargs rm -f; \
	rm -f header.dvi header.log header.pdf _region_* \
		summary.pdf cv_vishnu.pdf header.out
